package com.wk.kxexamadminister.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wk.kxexamadminister.entity.*;
import com.wk.kxexamadminister.mapper.JudgmentMapper;
import com.wk.kxexamadminister.mapper.ManyChoiceMapper;
import com.wk.kxexamadminister.mapper.SingleMapper;
import com.wk.kxexamadminister.mapper.fillBlanksMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

import static com.wk.kxexamadminister.controller.ChoiceController.aVoid;

@Controller
public class demo {

    @Autowired
    private SingleMapper singleMapper;
    @Autowired
    private ManyChoiceMapper manyChoiceMapper;
    @Autowired
    private JudgmentMapper judgmentMapper;
    @Autowired
    private fillBlanksMapper fillBlanksMapper;


    @GetMapping("/toDemo")
    @ResponseBody
    public List<Object> demoChoice(Integer cId){

        cId=1;

        List<SingleChoiceExt> singleChoices = singleMapper.findAllSingleChoice(cId);
        for (SingleChoiceExt singleChoice : singleChoices) {
            singleChoice.setDescription(aVoid(singleChoice.getDescription()));
        }
        Collections.shuffle(singleChoices);

        List<ManyChoice> manyChoices = manyChoiceMapper.findLimitManyChoice(cId);
        Collections.shuffle(manyChoices);


        List<Judgment> judgments = judgmentMapper.findLimitJudgment(cId);
        Collections.shuffle(judgments);

        List<fillBlanks> fillBlanks = fillBlanksMapper.findLimitfillBlanks(cId);
        Collections.shuffle(fillBlanks);



        ArrayList<Object> list = new ArrayList<>();
        list.add(singleChoices);
        list.add(manyChoices);
        list.add(judgments);
        list.add(fillBlanks);







        return list;
    }


@GetMapping("/todemo")
    public String a(){
        return "/demoChoice";
}


}
